home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / var / lib / dpkg / info / ca-certificates.postinst < prev    next >
Text File  |  2008-06-03  |  4KB  |  147 lines

  1. #! /bin/sh -e
  2. # postinst script for ca-certificates
  3. #
  4. # see: dh_installdeb(1)
  5.  
  6. # summary of how this script can be called:
  7. #        * <postinst> `configure' <most-recently-configured-version>
  8. #        * <old-postinst> `abort-upgrade' <new version>
  9. #        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
  10. #          <new-version>
  11. #        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
  12. #          <failed-install-package> <version> `removing'
  13. #          <conflicting-package> <version>
  14. # for details, see /usr/share/doc/packaging-manual/
  15. #
  16. # quoting from the policy:
  17. #     Any necessary prompting should almost always be confined to the
  18. #     post-installation script, and should be protected with a conditional
  19. #     so that unnecessary prompting doesn't happen if a package's
  20. #     installation fails and the `postinst' is called with `abort-upgrade',
  21. #     `abort-remove' or `abort-deconfigure'.
  22.  
  23. each_value() {
  24.  echo "$l" |tr ',' '\n' | sed -e 's/^[[:space:]]*//' 
  25. }
  26.  
  27. memberp() {
  28.  m="$1"
  29.  l="$2"
  30.  each_value "$1" | grep -q "^$m\$"
  31. }
  32.  
  33. delca() {
  34.  m="$1"
  35.  l="$2"
  36.  echo "$l" |sed -e 's|'"$m"', ||' -e 's|'"$m"'$||' -e 's/,[[:space:]]*,/, /' -e 's/^[[:space:]]*//' -e 's/,[[:space:]]*$//'
  37. }
  38.  
  39. case "$1" in
  40.     configure)
  41.         if dpkg --compare-versions "$2" lt 20030414; then
  42.         # remove old *.pem files that ca-certificates installed 
  43.         (cd /etc/ssl/certs; rm -f $(cat /usr/share/doc/ca-certificates/oldpemfiles))
  44.     fi
  45.         . /usr/share/debconf/confmodule
  46.     db_version 2.0
  47.     db_capb multiselect
  48.     db_metaget ca-certificates/enable_crts choices
  49.     CERTS_AVAILABLE="$RET"
  50.     db_get ca-certificates/enable_crts
  51.     CERTS_ENABLED="$RET"
  52.     # XXX unmark seen for next configuration
  53.     db_fset ca-certificates/new_crts seen false
  54.     db_stop || true
  55.     if test -f /etc/ca-certificates.conf; then
  56.       # XXX: while in subshell?
  57.       while read line
  58.       do
  59.         if echo "$line" | grep -q '^#'; then
  60.          echo "$line"
  61.         else
  62.          case "$line" in
  63.          !*) ca=$(echo "$line" | sed -e 's/^!//');;
  64.          *)   ca="$line";;
  65.          esac
  66.          if memberp "$ca" "$CERTS_ENABLED"; then
  67.            echo "$ca"
  68.            # CERTS_ENABLED=$(delca "$ca" "$CERTS_ENABLED")
  69.          else
  70.            echo "!$ca"
  71.          fi
  72.          # CERTS_AVAILABLE=$(delca "$ca" "$CERTS_AVAILABLE")
  73.         fi
  74.       done < /etc/ca-certificates.conf > /etc/ca-certificates.conf.dpkg-new
  75.       if echo "$CERTS_ENABLED" | egrep -q "^([[:space:]]*,)*[[:space:]]*$"; then
  76.           :
  77.       else
  78.         each_value "$CERTS_ENABLED" | while read ca
  79.          do
  80.           if grep -q "^$ca" /etc/ca-certificates.conf.dpkg-new; then
  81.           :
  82.           else
  83.           echo "$ca" >> /etc/ca-certificates.conf.dpkg-new
  84.           fi
  85.             done
  86.       fi
  87.       each_value "$CERTS_AVAILABLE" | while read ca
  88.       do
  89.         if memberp "$ca" "$CERTS_ENABLED"; then
  90.         :
  91.         elif grep -q "^!$ca" /etc/ca-certificates.conf.dpkg-new; then
  92.             :
  93.         else
  94.         echo "!$ca" >> /etc/ca-certificates.conf.dpkg-new
  95.         fi
  96.       done
  97.       if cmp -s /etc/ca-certificates.conf /etc/ca-certificates.conf.dpkg-new; then
  98.         rm -f /etc/ca-certificates.conf.dpkg-new
  99.       else
  100.         mv -f /etc/ca-certificates.conf /etc/ca-certificates.conf.dpkg-old
  101.         mv /etc/ca-certificates.conf.dpkg-new /etc/ca-certificates.conf
  102.       fi
  103.     else
  104.       # new file
  105.       cat > /etc/ca-certificates.conf <<EOF
  106. # This file lists certificates that you wish to use or to ignore to be
  107. # installed in /etc/ssl/certs.
  108. # update-ca-certificates(8) will update /etc/ssl/certs by reading this file.
  109. #
  110. # This is autogenerated by dpkg-reconfigure ca-certificates.
  111. # Certificates should be installed under /usr/share/ca-certificates
  112. # and files with extension '.crt' is recognized as available certs.
  113. #
  114. # line begins with # is comment.
  115. # line begins with ! is certificate filename to be deselected.
  116. #
  117. EOF
  118.       (echo $CERTS_ENABLED | tr ',' '\n'; \
  119.        echo $CERTS_AVAILABLE | tr ',' '\n') | \
  120.         sed -e 's/^[[:space:]]*//' | \
  121.         sort | uniq -c | \
  122.         sed -e 's/^[[:space:]]*2[[:space:]]*//' \
  123.             -e 's/^[[:space:]]*1[[:space:]]*/!/' \
  124.         >> /etc/ca-certificates.conf
  125.     fi
  126.     update-ca-certificates
  127.     ;;
  128.  
  129.     abort-upgrade|abort-remove|abort-deconfigure)
  130.  
  131.     ;;
  132.  
  133.     *)
  134.         echo "postinst called with unknown argument \`$1'" >&2
  135.         exit 1
  136.     ;;
  137. esac
  138.  
  139. # dh_installdeb will replace this with shell code automatically
  140. # generated by other debhelper scripts.
  141.  
  142.  
  143.  
  144. exit 0
  145.  
  146.  
  147.